package com.menghai;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;

import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;

public class TestClone {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ArrayList<String> list = new ArrayList<String>();
		list.add("1");
		list.add("2");
		ArrayList<String> list2 = (ArrayList<String>) list.clone();
		System.out.println("list==list2 "+(list==list2));
		System.out.println(list2.get(0)+"   "+list2.get(1));
		ArrayList<String> list3 = list;
		System.out.println("list==list3 "+(list==list3));
		
//		
//		try {
//			KeyGenerator kg = KeyGenerator.getInstance("DES");
//		    kg.init(new SecureRandom());
//		    SecretKey key = kg.generateKey();
//		    SecretKeyFactory skf = SecretKeyFactory.getInstance("DES");
//		    Class spec = Class.forName("javax.crypto.spec.DESKeySpec");
//		    DESKeySpec ks = (DESKeySpec) skf.getKeySpec(key, spec);
//		    ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("F:/keyfile.txt"));
//		    oos.writeObject(ks.getKey());
//			
//			
//			Cipher c = Cipher.getInstance("DES/CFB8/NoPadding");
//			c.init(Cipher.ENCRYPT_MODE, key);
//		    CipherOutputStream cos = new CipherOutputStream(new FileOutputStream("F:/ciphertext.txt"), c);
//		    PrintWriter pw = new PrintWriter(new OutputStreamWriter(cos));
//		    pw.println("Stand and unfold yourself");
//		    pw.close();
//		    oos.writeObject(c.getIV());
//		    oos.close();
//		} catch (NoSuchAlgorithmException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (NoSuchPaddingException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
	}

}
